﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace _7DaysToDieTools.Class
{
    /// <summary>
    /// 网上配置文件config.xml操作类
    /// </summary>
    public static class NetConfig
    {
        /// <summary>
        /// 获取网上的config.xml文件
        /// </summary>
        /// <param name="overwrite">是否覆盖</param>
        public static void GetConfig(bool overwrite)
        {
            //检测处理
            if (overwrite)
            {
                if (File.Exists(Sinfo.Data.BasePath + Sinfo.Net.File.Config))
                {
                    File.Delete(Sinfo.Data.BasePath + Sinfo.Net.File.Config);
                }
            }
            else
            {
                if (File.Exists(Sinfo.Data.BasePath + Sinfo.Net.File.Config))
                {
                    return;
                }
            }
            //下载文件
            NetAction na = new NetAction();
            na.DownFile(Sinfo.Net.NetURL + Sinfo.Net.File.Config);
            while (!na.Comp)
            {
                System.Threading.Thread.Sleep(100);
                System.Windows.Forms.Application.DoEvents();
            }
        }
    }
}
